window._MANAGERROLELABEL = {

    _LATESTNPC:null,

    _TYPEDEFAULT:0,

    _TYPEZL:1,//关系类型中立
    _TYPEDD:2,//关系类型敌对
    _TYPEXJ:3,//关系类型下级
    _TYPESJ:4,//关系类型上级
    _TYPEBOSS:5,//关系类型首领
    _TYPEZXSJ:6,//关系类型直系上级
    _TYPEFR:7,//俘虏

    _TYPESTR:['无','中立','敌对','下级','上级','主公','上司','俘虏'],

    _DQCONF:{
                dq:{
                    successTalkCode:'005',
                    failTalkCode:'006',
                    successTalkType:'stealSuccess',
                    failTalkType:'stealFail',
                    actionname:'盗窃'
                },

                qz:{
                    successTalkCode:'007',
                    failTalkCode:'008',
                    successTalkType:'qiaozaSuccess',
                    failTalkType:'qiaozaFail',
                    actionname:'敲诈'
                },

                sh:{
                    successTalkCode:'009',
                    failTalkCode:'010',
                    successTalkType:'suohuiSuccess',
                    failTalkType:'suohuiFail',
                    actionname:'索贿'
                },
            },

    _PARENTNODE:null,

    _NPC:null,

    //功能选项
    _FUNCTYPE:[
        //基础
        {type:'调查',value:0,func:'checkRoleFunc'},
        {type:'交谈',value:0,func:'talkFunc'},
        {type:'交易',value:0,rtype:[1,3,4,5,6,7],func:'tradeFunc'},
        {type:'给予',value:0,rtype:[1,3,4,5,6,7],func:'giveFunc'},
        {type:'盗窃',value:0,sign:'mskk',func:'stealFunc'},//（妙手空空）
        {type:'切磋',value:0,rtype:[1,3,4,5,6],sign:'wc',func:'pkFunc'},//（武痴）

        //人际关系
        {type:'学艺',value:80,rtype:[1,3,4,5,6],sign:'hx',func:'studyFunc'},//友好度100 同阵营或者中立（好学）

        {type:'雇佣',value:0,rtype:[1],func:'buyRoleFunc'},//中立
        {type:'敲诈',value:0,rtype:[1],sign:'mh',func:'getMoneyByPowerFunc'},//中立（蛮横）
        {type:'暗杀',value:0,rtype:[1,2,7],sign:'cs',func:'killFunc'},//非同阵营 学会（刺杀）
        {type:'归化',value:0,rtype:[1,2,7],sign:'as',func:'cheatRoleFunc'},//友好度50 非同阵营（暗示）

        {type:'调遣',value:0,rtype:[3],func:'borrowRoleFunc'},/*同阵营且功勋小于主角*/ 
        {type:'索贿',value:0,rtype:[3],sign:'hh',func:'getMoneyByPosFunc'},//同阵营且功勋小于主角（厚黑）
        {type:'招募',value:100,rtype:[1,3,7],func:'getRoleFunc'},//友好度100 功勋小于主角 同阵营或者中立

        {type:'应聘',value:30,rtype:[1,4,5],func:'getJobFunc'},//友好度50  功勋大于主角同阵营 或者 主角无阵营
        {type:'请辞',value:0,rtype:[5,6],func:'giveupJobFunc'},
        {type:'任务',value:0,rtype:[1,3,4,5,6],func:'getWorkFunc'},/*直系上司*/
        {type:'行贿',value:0,rtype:[4,5,6],sign:'wgzd',func:'giveToUpFunc'},//（为官之道）
        {type:'火并',value:0,rtype:[5],sign:'yxj',func:'killBossFunc'},//功勋大于同阵营首领（野心家）
        
        
        //中立:雇佣 敲诈 招募 暗杀 归化 学艺 任务
        //敌对:暗杀 归化
        //同阵营下级:调遣 索贿 招募 学艺 任务
        //同阵营直系上级:应聘 请辞 火并 学艺 任务 行贿
    ],

    isSencondNpc:function(name){
        if(_NPC[name]&&_NPC[name].second){
            _TIPS.showMessage('二周目人物无法招募');
            return true;
        }
        return false;
    },

    getFuncValueOfType:function(type){

        for(var i=0;i<_MANAGERROLELABEL._FUNCTYPE.length;i++){

            var funcObj = _MANAGERROLELABEL._FUNCTYPE[i];
            if(funcObj.type==type){
                return funcObj.value;
            }

        }

        return 0;

    },

    getFuncOfType:function(type){

        for(var i=0;i<_MANAGERROLELABEL._FUNCTYPE.length;i++){

            var funcObj = _MANAGERROLELABEL._FUNCTYPE[i];
            if(funcObj.type==type){
                return funcObj.func;
            }

        }

        return null;
    },

    getEnableFunc:function(npc){

        return [{type:'调查'},{type:'交谈'},{type:'交易'}];
        
    },

    //获取npc的关系类型
    getRelationType:function(npc){

        //console.log('获取npc关系类型',npc);

        var npcRelation = _GAMEDATAHELPER.getNpcRelationType(npc);

        if(npcRelation==_MPEOPLE._ARRTYPEMIDDLE){
            return _MANAGERROLELABEL._TYPEZL;
        }else if(npcRelation==_MPEOPLE._ARRTYPEFRIEND){

            if(window.gameData.isMaster){
                return _MANAGERROLELABEL._TYPEXJ; 
            }

            var masterConf = _MASTER[window.gameData.country];
            if(masterConf.boss==npc){
                return _MANAGERROLELABEL._TYPEBOSS;
            }

            if(window.gameData.master==npc){
                return _MANAGERROLELABEL._TYPEZXSJ;
            }

            var npcconf = _NPC[npc];
            if(!npcconf.title){
                return _MANAGERROLELABEL._TYPEXJ;
            }
            
            var npclevelFight = _HONOUR._EXP[npcconf.title];

            //console.log(npcconf,npclevelFight,window.gameData.levelFight);

            if(window.gameData.levelFight<npclevelFight)
                return _MANAGERROLELABEL._TYPESJ;
            else{
                return _MANAGERROLELABEL._TYPEXJ;
            }
        }else if(npcRelation==_MPEOPLE._ARRTYPEARMY){
           
            if(_MANAGERROLELABEL.isNpcFr(npc)){
                return _MANAGERROLELABEL._TYPEFR;
            }
            return _MANAGERROLELABEL._TYPEDD;
        }

        return _MANAGERROLELABEL._TYPEDEFAULT;

    },

    isNpcFr:function(npc){
        var npclog = _GAMEDATAHELPER.getNpcLog(npc);
        var npccountry = npclog.country;
        var npccity = npclog.city;
        if(
            window.gameData.cityLog[npccity]!=npccountry
            &&window.gameData.country
            &&window.gameData.cityLog[npccity]==window.gameData.country
        ){
            return true;
        }else{
            return false;
        }
    },

    showLabel:function(npc,parentNode){

        if(npc)
        _MANAGERROLELABEL._LATESTNPC = npc.t;

        _MANAGERROLELABEL._NPC = npc;

        _MANAGERROLELABEL._PARENTNODE=parentNode;

        var roleLabelObj = _GRM.getNodeObj('roleLabel');
        var roleLabel = roleLabelObj.node;

        if(roleLabelObj.isnew){
            roleLabel.getChildByName('mask')
            .on(cc.Node.EventType.TOUCH_START, _CU.cancelFunc, roleLabel);

            var btns = roleLabel.getChildByName('role').getChildByName('btns').getChildren();
            for(var i=0;i<btns.length;i++){
                btns[i].roleLabel = roleLabel;
                btns[i].on(cc.Node.EventType.TOUCH_START, _MANAGERROLELABEL.btnClick, btns[i]);
                btns[i].functype = null;
            }

        }

        _MANAGERROLELABEL.refreshLabel(npc,roleLabel);

        parentNode.addChild(roleLabel);
    },


    refreshButtons:function(npc,roleLabel){

        var btns = roleLabel.getChildByName('role').getChildByName('btns').getChildren();
        var tempfuncarr = _MANAGERROLELABEL.getEnableFunc(npc);
        for(var i=0;i<btns.length;i++){
            if(tempfuncarr[i]){
                btns[i].active = true;
                if(tempfuncarr[i].value){
                    btns[i].getChildByName('Background').getChildByName('Label')
                    .getComponent(cc.Label).string = tempfuncarr[i].type+"("+tempfuncarr[i].value+")";
                }else{
                    btns[i].getChildByName('Background').getChildByName('Label')
                    .getComponent(cc.Label).string = tempfuncarr[i].type;
                }
                btns[i].functype = tempfuncarr[i].type;
            }else{
                btns[i].active = false;
            }
        }

    },


    refreshLabel:function(npc,roleLabel){

        var info = roleLabel.getChildByName('role').getChildByName('info');
        var npcconf = _NPC[npc.t];
        var npcface = npcconf.face;
        info.getChildByName('baseinfo').getComponent(cc.Label).string = _MANAGERROLELABEL.getNpcInfo(npc);
        info.getChildByName('face').getComponent(cc.Sprite).spriteFrame = _GRM.getFaceFrame(npcface);
        _MANAGERROLELABEL.refreshButtons(npc,roleLabel);
    },


    getNpcInfo:function(npc){

        //console.log('获取npc关系信息',npc);

        var npcconf = _NPC[npc.t];
        var npcname = npcconf.name;

        return "姓名:"+npcname+" "
                +"等级:"+npcconf.lv+"\n"
                +"职业:"+npcconf.job;
    },


    //战斗类指令
    pkFunc:function(){
        var talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'029','pkFight');;
        _MANAGERTALK.showTalk(_MANAGERROLELABEL._PARENTNODE,talkObj,_MAP);;
    },
    studyFunc:function(){
        //_TIPS.showMessage('学习');
        var talkObj = null;
        var npclog = _GAMEDATAHELPER.getNpcLog(_MANAGERROLELABEL._NPC.t);
		/*
        if(npclog.country!='中立'&&npclog.country!=window.gameData.country){
            talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'0113','studyFaile');
        }else{
            if(_GAMEDATAHELPER.canStudy(_MANAGERROLELABEL._NPC.t)){
                var enableSkillArr = _GAMEDATAHELPER.getEnableSkillOfNpc(_MANAGERROLELABEL._NPC.t);
                if(enableSkillArr&&enableSkillArr.length>0){
                    talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'011','studyFight');
                }else{
                    talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'0111','studyFaile');
                }
            }else{
                talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'0112','studyFaile');
            }
        }
		*/
		if(_GAMEDATAHELPER.canStudy(_MANAGERROLELABEL._NPC.t)){
			var enableSkillArr = _GAMEDATAHELPER.getEnableSkillOfNpc(_MANAGERROLELABEL._NPC.t);
			if(enableSkillArr&&enableSkillArr.length>0){
				talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'011','studyFight');
			}else{
				talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'0111','studyFaile');
			}
		}else{
			talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'0112','studyFaile');
		}
        _MANAGERTALK.showTalk(_MANAGERROLELABEL._PARENTNODE,talkObj,_MAP);
    },
    killFunc:function(){
        //_TIPS.showMessage('暗杀');
        var npclog = _GAMEDATAHELPER.getNpcLog(_MANAGERROLELABEL._NPC.t);

        if(
            npclog
            &&
            (
                npclog.zm
                ||npclog.dq
                ||npclog.gy
            )
        ){
			_TIPS.showMessage('无法暗杀队友');
			return;
		}
		
		if(npclog&&npclog.die){
			_TIPS.showMessage('此人已死有事烧纸');
			return;
		}

        //判定是否主公
        if(npclog&&_GAMEDATAHELPER.isNpcMaster(_MANAGERROLELABEL._NPC.t)&&!_MASTERHELPER.isCountryOver(npclog.country)){

            if(_MASTERHELPER.getCountryPlayer(npclog.country)>1){
                _TIPS.showMessage('势力还有其他武将时无法暗杀主公');
                return;
            }

        }
		
        var talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'012','killFight');
        _MANAGERTALK.showTalk(_MANAGERROLELABEL._PARENTNODE,talkObj,_MAP);
    },
    killBossFunc:function(){
        //_TIPS.showMessage('火并');
        if(_GAMEDATAHELPER.isNpcMaster(_MANAGERROLELABEL._NPC.t)){

            var npcconf = _NPC[_MANAGERROLELABEL._NPC.t];
            var npclevelFight = _HONOUR._EXP[npcconf.title];
            //console.log('火并:',window.gameData.levelFight,npclevelFight,npcconf);
            if(window.gameData.levelFight<npclevelFight){
                var talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'0131','killBossFightFaile');
                _MANAGERTALK.showTalk(_MANAGERROLELABEL._PARENTNODE,talkObj,_MAP);
            }else{
                var talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'013','killBossFight');
                _MANAGERTALK.showTalk(_MANAGERROLELABEL._PARENTNODE,talkObj,_MAP);
            }
        }else{
            _TIPS.showMessage('只能对主公使用该命令');
        }
    },
    //数值类指令
    giveFunc:function(){
        _MANAGERNMB.showNmbUi(_MAP.node,{type:_MANAGERNMB._TYPEGIVE,npc:_MANAGERROLELABEL._NPC,tipsnmb:100000});
    },
    giveToUpFunc:function(){
        //_TIPS.showMessage('行贿');
        _MANAGERNMB.showNmbUi(_MAP.node,{type:_MANAGERNMB._TYPEGIVEUP,npc:_MANAGERROLELABEL._NPC,tipsnmb:100000});
    },
    cheatRoleFunc:function(){
        //_TIPS.showMessage('归化');
        if(_HDLVHELPER.getHdLv()!=0){
            if(_GAMEDATAHELPER.getPlayerLv()<1000){
                _TIPS.showMessage('非简单难度下主角等级满1000才可以使用该命令');
                return ;
            }
        }

        var npclog = _GAMEDATAHELPER.getNpcLog(_MANAGERROLELABEL._NPC.t);
        if(
            npclog
            &&(
                !_GAMEDATAHELPER.isNpcMaster(_MANAGERROLELABEL._NPC.t)
                ||_MASTERHELPER.isCountryOver(npclog.country)
            )
        ){
            _MANAGERNMB.showNmbUi(_MAP.node,{type:_MANAGERNMB._TYPEGIVEARMY,npc:_MANAGERROLELABEL._NPC,tipsnmb:10000000});
        }else{
            _TIPS.showMessage('势力未灭亡无法主公使用该命令');
        }
    },
    //角色类指令
    buyRoleFunc:function(){
        //_TIPS.showMessage('雇佣');
        var talkObj = null;
        var npclog = _GAMEDATAHELPER.getNpcLog(_MANAGERROLELABEL._NPC.t);
        var npcconf = _NPC[_MANAGERROLELABEL._NPC.t];
        //var getnpcvalue = _MANAGERROLELABEL.getFuncValueOfType('雇佣')
        if(
            npclog
            &&!npclog.die
            &&!npclog.diq
            &&!npclog.gy
            &&!npclog.zm
            &&window.gameData.levelBright>=npcconf.lv
            //&&npclog.f>=getnpcvalue
        ){
            if(npclog.country!='中立'){
                talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'0201','guyongFail-1');
            }else if(window.gameData.playerTeam.length>=5){
                talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'0202','guyongFail-2');
            }else{
                npclog.gy = 1;
                var tmpplayer = _ROF.createRole(_MANAGERROLELABEL._NPC.t);
                tmpplayer.isCustomRole = true;
                window.gameData.playerTeam.push(tmpplayer);
                if(_MAP){
                    _MAP.removeNpc(_MANAGERROLELABEL._NPC.t);
                }
                talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'019','guyongSuccess');
            }
        }else{
            talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'020','guyongFail');
        }
        _MANAGERTALK.showTalk(_MANAGERROLELABEL._PARENTNODE,talkObj,_MAP);
    },

    getRoleFunc:function(){
        //_TIPS.showMessage('招募');
        var talkObj = null;
        var npclog = _GAMEDATAHELPER.getNpcLog(_MANAGERROLELABEL._NPC.t);
        var npcconf = _NPC[_MANAGERROLELABEL._NPC.t];
        var roleData = _ROLEDATA.getRoleDataOfPlayer(window.gameData.playerTeam[0]);
        var isMaster = _GAMEDATAHELPER.isNpcMaster(_MANAGERROLELABEL._NPC.t);
        var getnpcvalue = _MANAGERROLELABEL.getFuncValueOfType('招募')
        if(
            npclog
            &&!npclog.die
            &&!npclog.diq
            &&!npclog.gy
            &&!npclog.zm
            &&npclog.f>=getnpcvalue
        ){
            if(
				isMaster
				&&!_MASTERHELPER.isCountryOver(npclog.country)
			){
                talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'0241','zhaomuFail-1');
            }else if((npcconf.lv-100)>roleData.lv){
                talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'0242','zhaomuFail-2');
            }else if(npclog.country!='中立'
					&&npclog.country!=window.gameData.country
					&&!_MASTERHELPER.isCountryOver(npclog.country)
                    &&!_MANAGERROLELABEL.isNpcFr(_MANAGERROLELABEL._NPC.t)
			){
                talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'0243','zhaomuFail-3');
            }else{
                if(_HDLVHELPER.getHdLv()==0){
                    /*
                    npclog.zm = 1;
                    _GAMEDATAHELPER.addLevelData('levelBright',10);
                    var tmpplayer = _ROF.createRole(_MANAGERROLELABEL._NPC.t);
                    tmpplayer.equip={};
                    if(window.gameData.playerTeam.length<5)
                        window.gameData.playerTeam.push(tmpplayer);
                    else
                        window.gameData.playerTeamBack .push(tmpplayer);
                    */
                    _GAMEDATAHELPER.zhaomuNpc(_MANAGERROLELABEL._NPC.t);
                    if(_MAP){
                        _MAP.removeNpc(_MANAGERROLELABEL._NPC.t);
                    }
                    talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'023','zhaomuSuccess');
                }else{
                    talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'0231','zhaomuFight');
                }
            }
        }else{
            talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'024','zhaomuFail-4');
        }
        _MANAGERTALK.showTalk(_MANAGERROLELABEL._PARENTNODE,talkObj,_MAP);
    },

    borrowRoleFunc:function(){
        //_TIPS.showMessage('调遣');
        var talkObj = null;
        var isMaster = _GAMEDATAHELPER.isNpcMaster(_MANAGERROLELABEL._NPC.t);
        var npclog = _GAMEDATAHELPER.getNpcLog(_MANAGERROLELABEL._NPC.t);
        if(
            npclog
            &&!npclog.die
            &&!npclog.diq
            &&!npclog.gy
            &&!npclog.zm
        ){
            if(isMaster){
                talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'0222','diaoqianFail-1');
            }else if(window.gameData.playerTeam.length>=5){
                talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'022','diaoqianFail-2');
            }else{
                npclog.diq = 1;
                var tmpplayer = _ROF.createRole(_MANAGERROLELABEL._NPC.t);
                tmpplayer.isCustomRole = true;
                window.gameData.playerTeam.push(tmpplayer);
                if(_MAP){
                    _MAP.removeNpc(_MANAGERROLELABEL._NPC.t);
                }
                talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'021','diaoqianSuccess');
            }
        }else{
            talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'0221','diaoqianFail-3');
        }
        _MANAGERTALK.showTalk(_MANAGERROLELABEL._PARENTNODE,talkObj,_MAP);
    },


    randomItem:function(npc,lv){

        var npcConf = _NPC[npc];

        if(npc&&npcConf&&_SPE[npc]&&Math.random()<0.1){
            var getitem = _SPEHELPER.createSpe(npc);
            _GAMEDATAHELPER.pushItem(getitem);
            return getitem.type;
        }else{

            var randomPer = Math.random();

            if(randomPer<0.25){

                var getitem = _SPEHELPER.createSpeByNpc(npc);
                _GAMEDATAHELPER.pushItem(getitem);
                if(getitem){
                    return getitem.type;
                }

            }else if(randomPer<0.5&&lv){
            
                var getmoney = lv*10000;
                _GAMEDATAHELPER.oprMoney(getmoney);
                return "钱"+getmoney;
            
            }else if(
                    randomPer<0.75
                    &&npcConf
                    &&npcConf.skill
                    &&npcConf.skill.length>0
                    ){

                var randomSkill = _CU.randomObj(npcConf.skill);
                _GAMEDATAHELPER.pushItem(_IOF.createObjByName(randomSkill,null));
                return randomSkill;

            }else{

                var randomItem = _FIGHTITEMHELPER.randomItemByLevel(lv);
                _GAMEDATAHELPER.pushItem(_IOF.createObjByName(randomItem,null));
                return randomItem;
            }
        }

    },

    getItemFuc:function(type,npc){

        var talkObj = null;
        var npcConf = _NPC[npc];
        var isSuccess = false;
        var failreason = "未知原因";
        var actionConf = _MANAGERROLELABEL._DQCONF[type];
        var successTalkCode = actionConf.successTalkCode;
        var failTalkCode = actionConf.failTalkCode;
        var successTalkType = actionConf.successTalkType;
        var failTalkType = actionConf.failTalkType;
        var actionname = actionConf.actionname;

        if(!npcConf.cha
            ||!_CHARACTER[npcConf.cha]
            ||_CHARACTER[npcConf.cha][type]){
            isSuccess=true;
        }else{
            failreason="对性格\""+npcConf.cha+"\"的角色进行"+actionname+"无效";
        }

        if(isSuccess){
            _GAMEDATAHELPER.addLevelData('levelDark',10);
            var itemmessage = _MANAGERROLELABEL.randomItem(npc,npcConf.lv);
            
            talkObj = _TALKHELPER.createCommonTalkWithParam(
                        _MANAGERROLELABEL._NPC,successTalkCode,successTalkType,
                        {message:itemmessage+",恶名上升"+10}
                    );
        }else{
            talkObj = _TALKHELPER.createCommonTalkWithParam(_MANAGERROLELABEL._NPC,failTalkCode,failTalkType,
                        {message:failreason}
                    );
        }


        _MANAGERTALK.showTalk(_MANAGERROLELABEL._PARENTNODE,talkObj,_MAP);

    },


    //索取类指令
    stealFunc:function(){
        //_TIPS.showMessage('盗窃');
        _MANAGERROLELABEL.getItemFuc('dq',_MANAGERROLELABEL._NPC.t);
    },

    getMoneyByPosFunc:function(){
        _MANAGERROLELABEL.getItemFuc('sh',_MANAGERROLELABEL._NPC.t);
    },

    getMoneyByPowerFunc:function(){
        //_TIPS.showMessage('敲诈');
        _MANAGERROLELABEL.getItemFuc('qz',_MANAGERROLELABEL._NPC.t);
    },

    //其他指令
    checkRoleFunc:function(){
        var tmpnpc = _ROF.createRole(_MANAGERROLELABEL._NPC.t);
        _MRDL.initUi(_MANAGERROLELABEL._PARENTNODE,{sence:_STYPE._FIGHTSENCE,roleArr:[tmpnpc]});
    },

    tradeFunc:function(){
        _MG.initUi(_MANAGERROLELABEL._PARENTNODE,{sence:_STYPE._SHOPSENCE,npc:_MANAGERROLELABEL._NPC});
    },

    talkFunc:function(){
        //_MANAGERTALK.showTalk(_MANAGERROLELABEL._PARENTNODE,_TALKCONFIG['001'],_MAP);
        var npclog = _GAMEDATAHELPER.getNpcLog(_MANAGERROLELABEL._NPC.t);
        var npcconf = _NPC[_MANAGERROLELABEL._NPC.t];
        //console.log('npc日志:',npclog);
        var talkObj = null;
        if(!npclog||!npclog.sign){
            var talktype = null;
            if(npclog&&!npclog.sign){
                _GAMEDATAHELPER.addLevelData('levelBright',1);
                npclog.sign=1;
                if(_GAMEDATAHELPER.hasTeamSkill('huhua')&&npcconf&&npcconf.sex==0){
                    talktype='0011';
                    npclog.f=100;
                }else if(_GAMEDATAHELPER.reduceItemByName('介绍信')){
                    //console.log('使用介绍信');
                    talktype='0012';
                    npclog.f=100;
                }else{
                    npclog.f=1;
                }
            }
            talkObj = _TALKHELPER.createFirstTalk(_MANAGERROLELABEL._NPC,talktype);
        }else{
            talkObj = _TALKHELPER.createNormalTalk(_MANAGERROLELABEL._NPC);
        }
        _MANAGERTALK.showTalk(_MANAGERROLELABEL._PARENTNODE,talkObj,_MAP);
    },

    getJobFunc:function(){
        //_TIPS.showMessage('应聘');
        var talkObj = null;
        var getjobvalue = _MANAGERROLELABEL.getFuncValueOfType('应聘')
        var npclog = _GAMEDATAHELPER.getNpcLog(_MANAGERROLELABEL._NPC.t);

        if(npclog&&npclog.country!='中立'&&_MASTER[npclog.country]){
            
            if(npclog.f>=getjobvalue){

                var countryConf = _MASTER[npclog.country];
                if(!countryConf.condition||window.gameData.levelBright>=countryConf.condition){
                    window.gameData.master = _MANAGERROLELABEL._NPC.t;
                    window.gameData.country = npclog.country;   
                    talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'015','getJobSuccess');
                }else{
                    talkObj = _TALKHELPER.createCommonTalkWithParam(_MANAGERROLELABEL._NPC,'0162','getJobFail',
                        {country:countryConf.name,nmb:countryConf.condition}
                    );
                }
            }else{
                talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'016','getJobFail');
            }
            
        }else{

            talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'0161','getJobFail');

        }
        _MANAGERTALK.showTalk(_MANAGERROLELABEL._PARENTNODE,talkObj,_MAP);
    },

    giveupJobFunc:function(){
        //_TIPS.showMessage('请辞');
        window.gameData.master = null;
        window.gameData.country = null;
        var npclog = _GAMEDATAHELPER.getNpcLog(_MANAGERROLELABEL._NPC.t);
        if(npclog){
            npclog.f=0;
        }
        for(var i=0;i<window.gameData.playerTeam.length;){
            var player = window.gameData.playerTeam[i];
            var playerlog = _GAMEDATAHELPER.getNpcLog(player.name);
            if(
                playerlog&&
                player.isCustomRole&&
                playerlog.country!='中立'){
                playerlog.diq=0;
                playerlog.zm=0;
                playerlog.gy=0;
                window.gameData.playerTeam.splice(i,1);
            }else{
                i++;
            }
        }
        _GAMEDATAHELPER.addLevelData('levelFight',-_HONOUR._EXPMAX);
        _GAMEDATAHELPER.addLevelData('levelBright',-100);
        var talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'014','giveupJob');
        _MANAGERTALK.showTalk(_MANAGERROLELABEL._PARENTNODE,talkObj,_MAP);
    },
    
    getWorkFunc:function(){
        //_TIPS.showMessage('任务');
        var talkObj = null;
        if(window.gameData.workList.length<5){
            var sameFlag = false;
            for(var i=0;i<window.gameData.workList.length;i++){
                if(window.gameData.workList[i].npc==_MANAGERROLELABEL._NPC.t){
                    sameFlag=true;
                }
            }
            if(!sameFlag){
                var randomWork = _GAMEDATAHELPER.randomWork(_MANAGERROLELABEL._NPC.t,null);
                if(randomWork){
                    window.gameData.workList.push(randomWork);
                    talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'017','getworkSuccess');
                }else{
                    talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'0182','getworkFail');
                }
            }else{
                talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'0181','getworkFail');
            }
        }else{
            talkObj = _TALKHELPER.createCommonTalk(_MANAGERROLELABEL._NPC,'018','getworkFail');
        }
        _MANAGERTALK.showTalk(_MANAGERROLELABEL._PARENTNODE,talkObj,_MAP);
    },


    btnClick:function(){

        console.log(this.functype);
        _GRM.putNode(this.roleLabel);
        var func = _MANAGERROLELABEL.getFuncOfType(this.functype);
        if(func){
            _MANAGERROLELABEL[func]();
        }else{
            _TIPS.showMessage(this.functype+"未实现");
        }

    }

    
}